home *** CD-ROM | disk | FTP | other *** search
- Path: druid.borland.com!usenet
- From: pete@borland.com (Pete Becker)
- Newsgroups: comp.os.ms-windows.programmer.tools.misc,comp.os.ms-windows.programmer.win32,comp.os.ms-windows.programmer.misc,comp.lang.c++
- Subject: Re: [Q] Why doesn't this compile?
- Date: 18 Apr 1996 17:40:01 GMT
- Organization: Borland International
- Message-ID: <4l5uph$ng9@druid.borland.com>
- References: <317523C0.5042@eps.agfa.be> <4l3hlj$6qt@mozo.cc.purdue.edu>
- NNTP-Posting-Host: pbecker.borland.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <4l3hlj$6qt@mozo.cc.purdue.edu>, hillca@cs.purdue.edu says...
- >
- >In article <317523C0.5042@eps.agfa.be>, rorlic@eps.agfa.be says...
- >>test.cpp(18) : error C2352: 'A::L::f' : illegal call of
- >>nonstatic member function
- >>Error executing cl.exe.
- >>test.obj - 1 error(s), 1 warning(s)
- >>
- >>------------------------------------------------
- >>
- >>Anybody knows what's wrong with it?
- >>Thanks,
- >>
- >>-- Ranko.
- >
- >I think the error message is telling you exactly what is wrong. You can't
- call
- >A::L::f because it is not a static function. A static function is shared
- >between all instances of the class (it only has access to other static
- >members), while nonstatic functions all have have access to the instance
- >specific data of the class.
- >
- >A::L::f requires that f is a static function. Which A object do you expect
- the
- >compiler to call f for?
-
- There is no A object involved. B::L is derived from A::L, and the call
- A::L::f() is calling the f() that's defined in A::L. This call is legal. It's
- the compiler that's wrong.
-
-